#include <iostream>
#include <string>
#include <vector>
#include <sw/redis++/redis++.h>
#include "utill.hpp"

using std::cout;
using std::endl;
using std::string;
using std::vector;

using sw::redis::Redis;

void test1(Redis &redis)
{
    redis.flushall();

    redis.hset("key", "f1", "111");
    redis.hset("key", {std::make_pair("f2", "222"),
                       std::make_pair("f3", "333")});

    vector<std::pair<string, string>> fields{
        {"f4", "444"},
        {"f5", "555"}};
    redis.hset("key", fields.begin(), fields.end());

    long long len = redis.hlen("key");
    cout << "len: " << len << endl;

    vector<string> results;
    auto it = std::back_inserter(results);
    redis.hmget("key", {"f1", "f2", "f3", "f4", "f5"}, it);

    PrintContainer(results);
}

int main()
{
    Redis redis("tcp://127.0.0.1:6379");

    test1(redis);

    return 0;
}